package jzqb.service.impl;

import jzqb.bo.CollectClassifyBo;
import jzqb.bo.CollectDataBo;
import jzqb.common.ContainUtils;
import jzqb.dao.CollectClassifyDao;
import jzqb.dao.CollectDataDao;
import jzqb.service.CollectClassifyService;
import jzqb.service.CollectDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yqt.com.cnki.bo.CollectionBo;
import yqt.com.cnki.service.PersonCenterService;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 关注公众号：MarkerHub
 * @since 2020-09-22
 */
@Service
public class CollectClassifyServiceImpl implements CollectClassifyService {


    @Autowired
    CollectClassifyDao collectClassifyDao;

    @Autowired
    CollectDataService collectDataService;

    @Autowired
    CollectDataDao collectDataDao;

    @Autowired
    PersonCenterService  personCenterService;


    @Override
    public Boolean insertCollectClassify(CollectClassifyBo collectClassifyBo) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String dateTime = df.format(new Date());
        collectClassifyBo.setCreateTime(dateTime);
        return collectClassifyDao.insertCollectClassify(collectClassifyBo);
    }

    @Override
    public Boolean updateCollectClassify(CollectClassifyBo collectClassifyBo) {
        return collectClassifyDao.updateCollectClassify(collectClassifyBo);
    }

    @Override
    public Boolean deleteCollectClassify(CollectClassifyBo collectClassifyBo) {
        // 收先通过分类ID拿到所有的数据  然后在进行删除
        CollectionBo collectionBo = new CollectionBo();
        collectionBo.setUserId(collectClassifyBo.getUserID());
        collectionBo.setClassifyId(collectClassifyBo.getId());
        Boolean result = personCenterService.deleteCollectionbyId(collectionBo);
        Boolean res = collectClassifyDao.deleteCollectClassify(collectClassifyBo);
        return res;
    }

    @Override
    public CollectClassifyBo getCollectClassifyByName(CollectClassifyBo collectClassifyBo) {
        return collectClassifyDao.getCollectClassifyByName(collectClassifyBo);
    }

    @Override
    public List<CollectClassifyBo> getCollectClassifyList(String userId) {
        return collectClassifyDao.getCollectClassifyList(userId);
    }
}